home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / latex209 / contrib / misc / pspic.sty < prev    next >
Text File  |  1991-07-10  |  8KB  |  210 lines

  1. \typeout{Document Style `PostScript PICTURE' v1.1b <apr 12 1991>.}
  2. %
  3. %----------------------------------------------------------------------
  4. %
  5. %    PostScript PICTURE
  6. %
  7. %    For use with DVIPS (by tomas rokicki)
  8. %
  9. %
  10. %    By: Kresten Krab Thorup, University of Aalborg, Denmark
  11. %        <krab@iesd.auc.dk>
  12. %        January 1991
  13. %
  14. %
  15. % Thanks to Rett Bull <RBULL@POMONA.CLAREMONT.EDU> for comments and 
  16. % bugreports.
  17. %----------------------------------------------------------------------
  18. %
  19. % ==================================
  20. %             psbox
  21. % ==================================
  22. % Bug fixed 91/04/12. Reported by Johannes Sixt.
  23. % (The `end' at the end of this macro had incidential become `en d')
  24. \def\psbox#1{%
  25.  \vbox{%
  26.   \hbox{%
  27.    \special{" \number\unitlength.0 65290.17 div dup scale 
  28.               picdict begin
  29.           /lwidth \number\@wholewidth.0 \number\unitlength.0 div def
  30.               lwidth setlinewidth    
  31.               \moveto(0,0) #1 end}}}}
  32. %
  33. % ==================================
  34. %  Commands for use in \psbox
  35. % ==================================
  36. %
  37. \def\moveto(#1,#2){ /x #1 def /y #2 def x y moveto}
  38. \def\rline(#1,#2){ newpath 
  39.          x y moveto 
  40.      #1 #2 rlineto 
  41.      linedash 0 setdash stroke 
  42.      /x x #1 add def 
  43.      /y y #2 add def}
  44. %
  45. % ==================================
  46. %   Commands for use in LaTeX 
  47. % ==================================
  48. %
  49. %----------------------------------------------------------------------
  50. % \line command of LaTeX
  51. %----------------------------------------------------------------------
  52. \def\line(#1,#2)#3{\psbox{%
  53.      \@ccolour setgray
  54.      /linedash \linedash def
  55.         #1 0 eq
  56.         {/fac{#2 div abs #3 mul}def} 
  57.         {/fac{#3 #1 abs div mul}def}
  58.         ifelse
  59.     \rline( #1 fac , #2 fac ) }}
  60. %----------------------------------------------------------------------
  61. % \putline(x1,y1)(x2,y2)
  62. %----------------------------------------------------------------------
  63. %\def\putline(#1,#2)(#3,#4){\put(#1,#2){\psbox{%
  64. %     \@ccolour setgray
  65. %     /linedash \linedash def
  66. %     \rline(#3 #1 sub,#4 #2 sub)
  67. %}}}
  68. %----------------------------------------------------------------------
  69. % \vector command of LaTeX
  70. %----------------------------------------------------------------------
  71. \def\vector(#1,#2)#3{\psbox{%
  72.    \@ccolour setgray
  73.    /linedash \linedash def 
  74.         #1 0 eq
  75.         {/fac{#2 div abs #3 mul}def} 
  76.         {/fac{#3 #1 abs div mul}def}
  77.         ifelse
  78.    newpath 
  79.       0 0 #1 fac #2 fac lwidth lwidth \number\headwidth.0 mul 
  80.       lwidth \number\headlength.0 mul arrow fill}}
  81. %----------------------------------------------------------------------
  82. % \putvector(x1,y1)(x2,y2)
  83. %----------------------------------------------------------------------
  84. %\def\putvector(#1,#2)(#3,#4){\put(#1,#2){\psbox{%
  85. %     \@ccolour setgray
  86. %     /linedash \linedash def
  87. %   newpath 
  88. %      0 0 #3 #1 sub #4 #2 sub lwidth lwidth \number\headwidth.0 mul 
  89. %      lwidth \number\headlength.0 mul arrow fill
  90. %}}}
  91. %----------------------------------------------------------------------
  92. % \circle and \circle* commands of LaTeX
  93. %----------------------------------------------------------------------
  94. \def\circle{\@ifstar{\@dot}{\@circle}}
  95. \def\@circle#1{\psbox{ newpath 
  96.           0 0 #1 2 div 0 360 arc 
  97.       [] 0 setdash 
  98.       \@ccolour setgray stroke}}
  99. \def\@dot#1{\psbox{newpath 
  100.           0 0 #1 2 div 0 360 arc 
  101.       \@ccolour setgray fill}}
  102. %----------------------------------------------------------------------
  103. % \ellipse(width,heigth) 
  104. % (suggested by Rett Bull)
  105. %----------------------------------------------------------------------
  106.           \def\ellipse(#1,#2){\@ifnextchar[%
  107.              {\@ellipse(#1,#2)}{\@ellipse(#1,#2)[full]}}
  108.           \def\@ellipse(#1,#2)#3{\psbox{%
  109.              #1 #2 scale newpath 0 0 0.5 e#3 arc [] 0 setdash stroke}}
  110. %----------------------------------------------------------------------
  111. % \bezier(x1,y1)(x2,y2)(x3,y3)
  112. %----------------------------------------------------------------------
  113. \def\bezier(#1,#2)(#3,#4)(#5,#6){%
  114. \psbox{#1 #2 #3 #4 #5 #6 curveto \@ccolour setgray \linedash 0 setdash stroke}%
  115. }%
  116. %----------------------------------------------------------------------
  117. % \oval command of LaTeX
  118. %----------------------------------------------------------------------
  119. \def\oval(#1,#2){\@ifnextchar[{\@oval(#1,#2)}{\@oval(#1,#2)[full]}}
  120. \def\@oval(#1,#2)[#3]{%
  121.    \begingroup 
  122.    \@ovxx = #1\unitlength 
  123.    \@ovyy =#2\unitlength 
  124.    \@tempdimb \ifdim \@ovyy >\@ovxx =\@ovxx\else =\@ovyy \fi 
  125.    \ifnum\@tempdimb>\maxovaldiam \@tempdimb=\maxovaldiam \fi 
  126.    \psbox{/rad \number\@tempdimb.0 \number\unitlength.0 div 2 div def 
  127.          /dx #1 2 div rad sub def 
  128.      /dy #2 2 div rad sub def 
  129.          \@ccolour setgray
  130.         newpath #3 [] 0 setdash stroke }%
  131.    \endgroup}
  132. %----------------------------------------------------------------------
  133. % \ctext{...}  Text to be written with the current grayscale
  134. %----------------------------------------------------------------------
  135. \def\ctext#1{\special{ps:gsave \@ccolour
  136.                   setgray}{}#1\special{ps:grestore}}
  137. %----------------------------------------------------------------------
  138. % Customization 
  139. %----------------------------------------------------------------------
  140. \def\vectorhead#1#2{\headlength=#1 \headwidth=#2 }
  141. \def\dashpattern[#1]{\xdef\linedash{[#1] }}        
  142. \def\colour#1{\def\@ccolour{\@nameuse{CC#1}}}
  143. \def\shade#1{\def\@ccolour{ 1 #1 100 div sub }}
  144. %
  145. % ==================================
  146. %          Initialization
  147. % ==================================
  148. %
  149. \newdimen\maxovaldiam 
  150. \maxovaldiam=14mm                   % Max diameter of LaTeX circle
  151. %
  152. \newcount\headlength                % length of arrowhead in terms of
  153.                     % linewidth
  154. \newcount\headwidth                 % width of arrowhead in terms of linewidth
  155. \vectorhead{9}{5}                   % default vectorhead dimentions
  156. %
  157. \dashpattern[]                      % set default type of linedashes 
  158. %
  159. \def\CCwhite{1 }
  160. \def\CCblack{0 }
  161. \def\CCgray{.5 }
  162. \def\CClightgray{.75 }
  163. \def\CCdarkgray{.25 }
  164. \colour{black}
  165. %----------------------------------------------------------------------
  166. % The P*stScr*pt dictionary
  167. %----------------------------------------------------------------------
  168. \special{!/picdict 200 dict def picdict begin 
  169. %
  170. %  Comamnds needed for ``ellipse''
  171. %
  172.          /etr {0 90} def     /etl {90 180} def    /et {0 180} def
  173.          /ebr {270 360} def  /ebl {180 270} def   /eb {180 360} def
  174.          /el {90 270} def    /er {-90 90} def     /efull {0 360}def
  175. %
  176. %  Comamnds needed for ``oval''
  177. %
  178. /tr { 0 0 moveto newpath dx dy rad 0 90 arc} def 
  179. /tl { 0 0 moveto newpath -1 dx mul dy rad 90 180 arc} def 
  180. /bl { 0 0 moveto newpath -1 dx mul -1 dy mul rad 180 270 arc} def 
  181. /br { 0 0 moveto newpath dx -1 dy mul rad 270 360 arc} def 
  182. /b { bl stroke newpath br -1 dx mul -1 dy mul rad sub moveto dx 2 mul
  183.      0 rlineto} def 
  184. /t { tl stroke newpath tr -1 dx mul dy rad add moveto dx 2 mul 0
  185.      rlineto } def
  186. /l { bl stroke newpath tl -1 dx mul rad sub -1 dy mul moveto 0 dy 2
  187.      mul rlineto } def 
  188. /r { tr stroke newpath br dx rad add -1 dy mul moveto 0 dy 2 mul
  189.      rlineto } def
  190. /full { t stroke newpath r stroke newpath b stroke newpath l } def 
  191. /mtrx matrix def 
  192. %
  193. /arrow { 
  194. /headlength exch def /halfheadthickness exch 2 div def
  195. /halfthickness exch 2 div def /tipy exch def /tipx exch def /taily
  196. exch def /tailx exch def /dx tipx tailx sub def /dy tipy taily sub def
  197. /arrowlength dx dx mul dy dy mul add sqrt def /angle dy dx atan def
  198. /base arrowlength headlength sub def /savematrix mtrx currentmatrix
  199. def tailx taily translate angle rotate gsave newpath 0 0 moveto base 0
  200. lineto linedash 0 setdash stroke grestore base halfheadthickness neg
  201. moveto arrowlength 0 lineto base halfheadthickness lineto base
  202. halfthickness lineto closepath savematrix setmatrix
  203. } def
  204. %%
  205. end}
  206. %----------------------------------------------------------------------
  207. %  end of pspic.sty
  208. %----------------------------------------------------------------------
  209.  
  210.